<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro" lang="zh" class="no-js">
<head th:include="common_include :: commonHead('仓库管理')"/>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>仓库管理</h5>
                </div>
                <div class="ibox-content">
                    <div class="row row-lg">
                        <div class="col-sm-12">
                            <form id="query-form">
                                <div class="row">
                                    <div class="col-sm-5">
                                        <div class="input-group m-b">
                                            <span class="input-group-addon">服务器</span>
                                            <input type="hidden" name="serverKey" id="serverKey"/>
                                            <input type="text" name="serverName" id="serverName" class="form-control" placeholder="服务器" readonly="true" onclick="selectSvnkitServerList()">
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-sm-5">
                                        <div class="input-group m-b">
                                            <span class="input-group-addon">仓库名称</span>
                                            <input type="text" name="repositoryName" id="repositoryName"
                                                   class="form-control" placeholder="仓库名称">
                                        </div>
                                    </div>
                                    <div class="col-sm-5">
                                        <div class="input-group m-b">
                                            <span class="input-group-addon">仓库描述</span>
                                            <input type="text" name="repositoryDesc" id="repositoryDesc"
                                                   class="form-control" placeholder="仓库描述">
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-sm-5">
                                        <div class="input-group m-b">
                                            <span class="input-group-addon">联系人名</span>
                                            <input type="text" name="contactsPerson" id="contactsPerson"
                                                   class="form-control" placeholder="联系人名">
                                        </div>
                                    </div>
                                    <div class="col-sm-5">
                                        <div class="input-group m-b">
                                            <span class="input-group-addon">联系邮箱</span>
                                            <input type="text" name="contactsEmail" id="contactsEmail"
                                                   class="form-control" placeholder="联系邮箱">
                                        </div>
                                    </div>
                                    <div class="col-sm-2">
                                        <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                                class="fa fa-search"></i>&nbsp;搜索</a>
                                    </div>
                                </div>
                            </form>
                            <div class="btn-group hidden-xs" id="toolbar" role="group">
                                <a class="btn btn-outline btn-primary btn-rounded"
                                   th:if="${@permission.hasPermission('svnkit:repositories:init')}"
                                   onclick="$.operate.post(ctx + 'service/svnkit/repositories/init',{serverKey:$('#serverKey').val()})"><i
                                        class="fa fa-inbox"></i> 反析</a>
                                <a class="btn btn-outline btn-warning btn-rounded"
                                   th:if="${@permission.hasPermission('svnkit:repositories:import')}"
                                   onclick="importPrepare()"><i
                                        class="fa fa-file-o"></i> 导入</a>
                                <a class="btn btn-outline btn-success btn-rounded"
                                   th:if="${@permission.hasPermission('svnkit:repositories:add')}"
                                   onclick="$.operate.add(0)"><i
                                        class="fa fa-plus"></i> 新增</a>
                                <a class="btn btn-outline btn-info btn-rounded"
                                   th:if="${@permission.hasPermission('svnkit:repositories:export')}"
                                   onclick="$.table.exportExcel()"><i
                                        class="fa fa-file-excel-o"></i> 导出</a>
                            </div>
                            <div class="col-sm-12 select-info table-striped">
                                <table id="bootstrap-table" data-mobile-responsive="true"></table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<form th:include="common_include :: importForm" id="importForm" enctype="multipart/form-data" class="form-horizontal m" style="display: none;"/>
</body>
<div th:include="common_include :: commonFoot"/>
<script th:src="@{/libs/service/js/service-svnkit.js}"></script>
<script th:inline="javascript">
    var editFlag = [[${@permission.displayWithPermission('svnkit:repositories:edit')}]];
    var viewFlag = [[${@permission.displayWithPermission('svnkit:repositories:view')}]];
    var rightFlag = [[${@permission.displayWithPermission('svnkit:repositories:right')}]];
    var dicts = [[${@dictCode.selectDictCodeByType('svnkit_repository_type')}]];
    var prefix = ctx + "service/svnkit/repositories";
    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            exportUrl: prefix + "/export",
            importTemplateUrl: prefix + "/importTemplate",
            importUrl: prefix + "/import/{formParam}",
            modalName: "仓库",
            search: false,
            showExport: false,
            columns: [{
                checkbox: true
            }, {
                field: 'rowKey',
                title: '主键ID',
                sortable: true,
                visible: false
            }, {
                field: 'repositoryName',
                title: '仓库名称',
                sortable: true
            }, {
                field: 'repositoryType',
                title: '仓库类型',
                sortable: true,
                formatter: function (value, row, index) {
                    return $.table.selectDictName(dicts, value);
                }
            }, {
                field: 'repositoryDesc',
                title: '仓库描述',
                sortable: true
            }, {
                field: 'contactsPerson',
                title: '联系人',
                sortable: true
            }, {
                field: 'contactsEmail',
                title: '联系人邮箱',
                sortable: true
            }, {
                title: '操作',
                align: 'center',
                formatter: function (value, row, index) {
                    var actions = [];
                    actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.rowKey + '\',\'' + row.repositoryName + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                    actions.push('<a class="btn btn-primary btn-xs ' + viewFlag + '" href="#" onclick="repositoryView(\'' + row.rowKey + '\',\'' + row.repositoryName + '\')"><i class="fa fa-list-ul"></i>浏览</a> ');
                    actions.push('<a class="btn btn-info btn-xs ' + rightFlag + '" href="#" onclick="repositoryRight(\'' + row.rowKey + '\',\'' + row.repositoryName + '\')"><i class="fa fa-edit"></i>权限</a> ');
                    return actions.join('');
                }
            }]
        };
        $.table.init(options);
    });

    function importPrepare() {
        if($("#serverKey").val() == "") {
            $.modal.alertError("请指定服务器");
        } else {
            $.table.importExcel('importForm',$('#serverKey').val())
        }
    }

    /*浏览仓库*/
    function repositoryView(id,name) {
        var url = prefix + '/repositoryView/' + id;
        createMenuItem(url, "【" + name + "】内容浏览");
    }

    /*权限管理*/
    function repositoryRight(id,name) {
        var url = prefix + '/repositoryRight/' + id;
        createMenuItem(url, "【" + name + "】权限管理");
    }
</script>
</html>